package com.csy.orm_ktorm.model

import org.ktorm.database.Database
import org.ktorm.entity.Entity
import org.ktorm.entity.sequenceOf
import org.ktorm.schema.*

interface Twitter : Entity<Twitter> {
    companion object : Entity.Factory<Twitter>()

    val id: Long

    var content: String

    var user: User
}


object Twitters : Table<Twitter>("twitter") {

    val id = long("id").primaryKey().bindTo { it.id }

    val content = varchar("content").bindTo { it.content }


    val userId = long("user_id").references(Users) { it.user }
}

val Database.twitters get() = this.sequenceOf(Twitters)
